package org.example.j1110nm2;


import org.apache.logging.log4j.message.Message;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/message")
public class messageWall {

    private List<MessageInFo> messageInFos = new ArrayList<MessageInFo>();

    //下面的这个英文单词表示的就是发布的意思
    @RequestMapping("/publish")
    public boolean publishMessage(MessageInFo messageInFo){
        if(!StringUtils.hasLength(messageInFo.getFrom())
                ||!StringUtils.hasLength(messageInFo.getTo())
                    ||!StringUtils.hasLength(messageInFo.getMessage())){
            return false;
        }
        //把这个输入的信息暂时存放到我们的这个内存里面去
        messageInFos.add(messageInFo);
        return true;
    }

    @RequestMapping("/getlist")
    public List<MessageInFo> getlist(){
        //直接把上面定义的这个代码进行返回
        return messageInFos;
    }
}
